You are here: Trading System Programming > Reference > Classes > Account > Account Methods > placeOrder

placeOrder

The placeOrder method places an order using a valid Order object.

Syntax

var placeOrder(order);

Parameters

order

Valid Order object for which to place the order.

 

Return Value

This method returns true if order was placed successfully, false otherwise.

Example

The following example demonstrates the use of placeOrder method.

 

function start()

{

//retrieve short positions for all symbols

var account = getAccount();

 

 

var placeLongOrder = false;

 

//determine whether a long order needs to be placed

..

..

..

 

if(placeLongOrder)

{

//prepare Order object

var order = new Order();

 

//retrieve current symbol, and apply it to the order

order.setSymbol(this.getSymbol());

 

//set order type to stop limit order

order.setOrderType(ORDERTYPE_STOPLIMIT);

 

//set action to buy order

order.setOrderAction(ACTIONTYPE_BUY);

 

//set time-in-force expiration to DAY so that the order expires at the end of the day

order.setTifType(TIFTYPE_DAY);

 

//set order quantity to 1000

order.setQuantity(1000);

 

//since this is a limit order, set the limit price to current Price

//get current time series and get the last price

var timeSeries = getTimeSeries(getSymbol());

var lastPrice = timeSeries.close(timeSeries.count() - 1);

 

order.setLimitPrice(lastPrice)

order.setStopPrice(lastPrice + 0.25);

 

//place the order

var rc = account.placeOrder(order);

}

}

See Also

start(), getAccount(), Order class

 


Copyright © 2006-2009 ActiveTick LLC